//
// Created by kqbi on 2020/2/10.
//

#ifndef ILPR_CONFIG_H
#define ILPR_CONFIG_H

#include <string>
#include <memory>

class Config {
public:

    class HttpServerInfo {
        ////    Attributes    ////

    public :

        inline uint32_t getPort() {
            return _port;
        }


        inline void setPort(uint32_t port) {
            _port = port;
        }

    private:

        uint32_t _port = 16973;
    };

    class DataBaseInfo {
        ////    Attributes    ////

    public :
        inline std::string getIsMysql() {
            return _isMysql;
        }

        inline std::string getDatabaseIp() {
            return _databaseIp;
        }

        inline int getDatabasePort() {
            return _databasePort;
        }

        inline std::string getDatabaseName() {
            return _databaseName;
        }

        inline std::string getDatabaseUserName() {
            return _databaseUserName;
        }

        inline std::string getDatabasePassword() {
            return _databasePassword;
        }

        inline void setIsMysql(std::string isMysql) {
            _isMysql = isMysql;
        }

        inline void setDatabaseIp(std::string databaseIp) {
            _databaseIp = databaseIp;
        }

        inline void setDatabasePort(int databasePort) {
            _databasePort = databasePort;
        }

        inline void setDatabaseName(std::string databaseName) {
            _databaseUserName = databaseName;
        }

        inline void setDatabaseUserName(std::string databaseUserName) {
            _databaseUserName = databaseUserName;
        }

        inline void setDatabasePassword(std::string databasePassword) {
            _databasePassword = databasePassword;
        }

    private:
        std::string _isMysql = "no";

        std::string _databaseIp = "127.0.0.1";        //## attribute _databaseIp

        int _databasePort = 3306;        //## attribute _databasePort

        std::string _databaseName = "ilpr";

        std::string _databaseUserName = "root";        //## attribute _databaseUserName

        std::string _databasePassword = "123456";        //## attribute _databasePassword

    };

    class LogInfo {
        ////    Attributes    ////

    public :
        inline int getLogType() {
            return _logType;
        }

        inline int getLogLevel() {
            return _logLevel;
        }

        inline std::string getMaxFileSize() {
            return _maxFileSize;
        }

        inline std::string getMaxBackupIndex() {
            return _maxBackupIndex;
        }

        inline void setLogType(int logType) {
            _logType = logType;
        }

        inline void setLogLevel(int logLevel) {
            _logLevel = logLevel;
        }

        inline void setMaxFileSize(std::string maxfilesize) {
            _maxFileSize = maxfilesize;
        }

        inline void setMaxBackupIndex(std::string maxbackupindex) {
            _maxBackupIndex = maxbackupindex;
        }

    private:
        int _logType = 1;

        int _logLevel = 6;

        std::string _maxFileSize = "50MB";

        std::string _maxBackupIndex = "5";
    };

    class BaseInfo {
        ////    Attributes    ////

    public :

        inline std::string getAppId() {
            return _appId;
        }

        inline void setAppId(std::string appId) {
            _appId = appId;
        }

        inline std::string getSdkKey() {
            return _sdkKey;
        }

        inline void setSdkKey(std::string sdkKey) {
            _sdkKey = sdkKey;
        }

        inline std::string getActiveKey() {
            return _activeKey;
        }

        inline void setActiveKey(std::string activeKey) {
            _activeKey = activeKey;
        }

        inline std::string getRgbLiveThreshold() {
            return _rgbLiveThreshold;
        }

        inline void setRgbLiveThreshold(std::string rgbLiveThreshold) {
            _rgbLiveThreshold = rgbLiveThreshold;
        }

        inline std::string getIrLiveThreshold() {
            return _irLiveThreshold;
        }

        inline void setIrLiveThreshold(std::string irLiveThreshold) {
            _irLiveThreshold = irLiveThreshold;
        }

        inline std::string getRgbCameraId() {
            return _rgbCameraId;
        }

        inline void setRgbCameraId(std::string rgbCameraId) {
            _rgbCameraId = rgbCameraId;
        }

        inline std::string getIrCameraId() {
            return _irCameraId;
        }

        inline void setIrCameraId(std::string irCameraId) {
            _irCameraId = irCameraId;
        }

        inline std::string getFilePath() {
            return _filePath;
        }

        inline void setFilePath(std::string filePath) {
            _filePath = filePath;
        }

    private:
        std::string _appId = "";
        std::string _sdkKey = "";
        std::string _activeKey = "";
        std::string _rgbLiveThreshold = "";
        std::string _irLiveThreshold = "";
        std::string _rgbCameraId = "";
        std::string _irCameraId = "";
        std::string _filePath = "";
    };

    Config();

    ~Config();

    static Config *getInstance();

    void setConfigFilePath(const char *configFilePath);

    bool init();

    bool parseConfigInfo(const char *path);

    std::string getTagInfo();

    void setTagInfo(std::string tagInfo);

    HttpServerInfo _httpServerInfo;

    DataBaseInfo _dataBaseInfo;

    LogInfo _logInfo;

    std::string _tagInfo;

    BaseInfo _baseInfo;
};


#endif //ILPR_CONFIG_H
